package com.lagou.edu.factory;

import com.lagou.edu.pojo.Company;
import org.springframework.beans.factory.FactoryBean;



/**
 * @author 10843
 */
public class CompanyFactoryBean implements FactoryBean<Company> {

    private String companyinfo;

    public void setCompanyinfo(String companyinfo) {
        companyinfo = companyinfo;
    }

    @Override
    public boolean isSingleton() {
        return true;
    }

    @Override
    public Company getObject() throws Exception {
        String[] split = companyinfo.split(",");
        // new一个复杂对象放进bean里边
        Company company = new Company();
        company.setAddress(split[1]);
        company.setName(split[0]);
        company.setScale(split[3]);
        return company;
    }

    @Override
    public Class<?> getObjectType() {
        return Company.class;
    }
}
